package com.coder306.controller;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.coder306.util.WebResult;

@RestController
public class LoginController {

	/**
	 * 登陆成功后返回SessionID,以后每次请求都带上
	 * @return
	 */
	@RequestMapping(value="login",method=RequestMethod.POST)
	@ResponseBody
	public WebResult login() {
		WebResult<Object> successResult = WebResult.getSuccessResult();
		Subject subject = SecurityUtils.getSubject();
		Session session = subject.getSession();
		successResult.put("jcookiename", session.getId());
		return successResult;
	}
	
}
